<?php

namespace app\common\validate;

use think\Validate;

class Dealer extends Validate
{
    protected $rule = [
        'logo' => 'require',
        'member_id' => 'require',
        'dealer_name' => 'require',

        'phone' => ['regex'=>'/^1[3|4|5|7|8][0-9]\d{4,8}$/i', 'require'],

        'province' => 'require',
        'city' => 'require',
        'area' => 'require',
        'street' => 'require',
        'address' => 'require',

//        'cover' => 'require',

        'level' => 'require',
        'duty_province' =>  'require',
        'duty_city' =>  'require',
        'duty_area' =>  'require',

//        'collecting_note' => 'require',

        'card_no' => 'require|checkCardNo',
        'proposer' => 'require',
        'id_card_in_hand' => 'require',
        'id_card_front' => 'require',
        'id_card_verso' => 'require',

        'business_license_name' => 'require',
        'business_license_num' => 'require',
        'business_license' => 'require',

        'lat' => 'require',
        'lon' => 'require',
    ];

    protected $message = [
        'member_id.require'=>  '400095',
        'repair_name.unique'=>  '400050',
        'repair_name.require'=>  '400096',

        'card_no.unique' =>  '400051',
        'card_no.require' =>  '400070',
        'card_no.checkCardNo'=>  400137,
        'proposer.unique' =>  '400098',
        'proposer.require' =>  '400070',
        'id_card_in_hand.require' =>  '400070',
        'id_card_front.require' =>  '400070',
        'id_card_verso.require' =>  '400070',

        'province.require' =>  '400101',
        'city.require' =>  '400101',
        'area.require' =>  '400101',
        'street.require' =>  '400101',
        'address.require' =>  '400101',

        'business_license_name.require' =>  '400072',
        'business_license_num.require' =>  '400072',
        'business_license.require' =>  '400072',

        'logo.require' =>  '400073',
        'cover.require' =>  '400104',

//        'collecting_note.require' =>  '400109',

        'phone.regex'=>  '400100',
        'phone.require'=>  '400106',

        'lat.require' =>  '400105',
        'lon.require' =>  '400105',

        'level.require'=>  '400107',
        'duty_province.require' =>  '400108',
        'duty_city.require' =>  '400108',
        'duty_area.require' =>  '400108',
    ];

    // 自定义验证规则
    protected function checkCardNo($value)
    {
        return checkCardNo($value);
    }
}